package com.demo.mykotlin.activity

import android.content.Intent
import android.os.Bundle
import android.view.View
import android.widget.Toast
import com.demo.mykotlin.R
import kotlinx.android.synthetic.main.activity_login.*

/**
 * 登录（页面）
 */
class LoginActivity : BaseActivity(), View.OnClickListener {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_login)
        loginBtn.setOnClickListener(this)
    }

    override fun onClick(v: View?) {
        when (v?.id) {
            R.id.loginBtn -> {
                val account = accountEt.text.toString()
                val password = passwordEt.text.toString()
                if (account == "admin" && password == "admin") {
                    val intent = Intent(this, AllFinishActivity::class.java)
                    startActivity(intent)
                } else {
                    Toast.makeText(this, "用户名或密码不正确", Toast.LENGTH_LONG).show()
                }
            }
        }
    }
}
